package com.dtguai.app.dao;

import com.dtguai.app.base.form.BaseFrom;
import com.dtguai.app.base.mapper.BaseMapper;
import com.dtguai.app.model.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 用户表
 *
 * @author guo
 * @date 2019-02-15 16:12:24
 */
public interface UserDao extends BaseMapper<User> {

    /**
     * 查询
     *
     * @param user 入参对象
     * @return 返回xml的List<User>对象
     */
    List<User> selectByUserModel(BaseFrom user);

    /**
     * Select标签 查询
     *
     * @param id id
     * @return User
     */
    @Select("select "
            + "id as id "
            + ",mobile as mobile  "
            + ",name as name  "
            + ",password as password  "
            + ",create_time as createTime  "
            + ",type as type  "
            + ",token as token  "
            + ",imei as imei  "
            + "from user "
            + "where id = #{id}")
    User findUserById(@Param("id") Integer id);

    /**
     * 根据用户名手机号查询用户信息
     * @param mobile 手机号
     * @param password 密码
     * @return User
     */
    @Select("select * from user where mobile = #{mobile} and password = #{password}")
    User login(@Param("mobile") String mobile, @Param("password") String password);

    /**
     * 根据手机号查询是否存在用户
     * @param mobile 手机号
     * @return User
     */
    @Select("select * from user where mobile = #{mobile}")
    User selectUserByMobile(@Param("mobile") String mobile);
}